package inventory.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import inventory.common.ResultData;
import inventory.entity.PermissionRecord;
import inventory.entity.User;
import inventory.mappers.MaterialTypicalMapper;
import inventory.mappers.UserPoMapper;
import inventory.service.PermissionRecordService;
import inventory.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author sxt
 * @create 2019-11-06 17:30
 */

@RestController
public class TestController {

    @Autowired
    private UserService userService;
    @Resource
    private PermissionRecordService permissionRecordService;

    @Resource
    private MaterialTypicalMapper materialTypicalMapper;

    @Autowired
    private UserPoMapper userPoMapper;

    @RequestMapping("test")
    public List<User> test(){
        List<User> users = userService.selectList(new EntityWrapper<User>());
        return users;
    }

    @RequestMapping("/testMP")
    public void testMP(){
        PermissionRecord record =new PermissionRecord();
        record.setUserId("1");
        record.setPermissionListId(3);
//        permissionRecordService.insert(record);

        permissionRecordService.update(record, new EntityWrapper<PermissionRecord>().eq("user_id", "2"));

//        permissionRecordService.select
    }

    @GetMapping("testUserPo")
    public String testUserPo(){

        System.out.println(userPoMapper.selectById("1"));

        return null;
    }

    @GetMapping("testHeader")
    public ResultData testSetHeader(HttpSession session){
        System.out.println(session.getId());
        return new ResultData().OK().setResultIns(session.getId());

    }
}
